package com.zyf.pattern.decorator.passport.upgrede;

import com.zyf.pattern.decorator.passport.old.ISiginService;
import com.zyf.pattern.decorator.passport.old.ResultMsg;

/**
 * create by yifeng
 */
public class SigninForThirdService implements ISigninForThirdService{

    private ISiginService service;

    public SigninForThirdService(ISiginService service) {
        this.service = service;
    }

    @Override
    public ResultMsg regist(String username, String password) {
        return service.regist(username, password);
    }

    @Override
    public ResultMsg login(String username, String password) {
        return service.login(username, password);
    }

    public ResultMsg loginForQQ(String openId) {
        // 1. openId是全局唯一，可以把它当做一个用户名
        // 2. 密码默认为null
        // 3. 注册（在原有的系统里面创建一个用户）
        // 4. 调用原来的登录方法
        return loginForRegist(openId, null);
    }

    public ResultMsg loginForWechat(String openId) {
        return null;
    }

    public ResultMsg loginForToken(String token) {
        // 通过token拿到用户信息，再重新登录一次
        return null;
    }

    public ResultMsg loginForTelphone(String telphone) {

        return null;
    }

    public ResultMsg loginForRegist(String username, String password) {

        ResultMsg msg = this.regist(username, null);

        msg = this.login(username, null);
        return null;
    }
}
